<!-- 03VueInstance.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
	<link rel="stylesheet" href="./css/common.css"/>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
	<!-- <script src="https://cdn.bootcss.com/axios/0.19.0/axios.min.js"></script> -->
	<!-- <script src="https://cdn.bootcss.com/lodash.js/4.17.15/lodash.min.js"></script> -->
</head>
<body>
	<h3>监听事件</h3>
	<p>v-on 中直接编写表达式</p>
	<div id="demo" class="div-demo-block">
		<button v-on:click="counter += 1">Add 1</button>
		<p>The button above has been clicked {{counter}} times.</p>
	</div>
	
    <script>
        var demo = new Vue({
			el: '#demo',
			data: {
				counter: 0
			}
        });
    </script>
	
	<p>v-on 绑定方法</p>
	<div id="demo2" class="div-demo-block">
		<!-- `greet` 是在下面定义的方法名 -->
		<button v-on:click="greet">Greet</button>
	</div>
	
    <script>
        var demo2 = new Vue({
			el: '#demo2',
			data: {
				name: 'wxg'
			},
			methods: {
				greet: function(event){
					alert("Hello " + this.name + "!")
					if (event) {
						alert(event.target.tagName)
					}
				}
			}
        });
    </script>
	
	<p>v-on 接收参数</p>
	<div id="demo3" class="div-demo-block">
		<!-- `greet` 是在下面定义的方法名 -->
		<button v-on:click="say('hi')">Say hi</button>
		<button v-on:click="say('what')">Say what</button>
	</div>
	
    <script>
        var demo3 = new Vue({
			el: '#demo3',
			methods: {
				say: function(msg){
					alert(msg)
				}
			}
        });
    </script>
	
	<p>特殊变量 $event 没有示例请直接阅读本章参考文档</p>
	
</body>
</html>